package org.example;

import java.io.File;
import java.io.IOException;

public class File_Demo4 {
    public static void main(String[] args) throws IOException {
        File file=new File("D:\\Idea_xiangmu\\IdeaProjects\\" +
                "Two_test\\src\\main\\java\\org\\example");
        System.out.println(haveFile(file));
    }
    public static boolean haveFile(File file){
        File[] files=file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()&&file1.getName().endsWith(".java")) {
                return true;
            }
        }
        return false;
    }
}
